package org.hawk.gwtppc.webtest.common;

/**
 * 
 * @author alex.bereznevatiy@gmail.com
 *
 */
public abstract class Asserts {
	public static void assertTrue(boolean value) {
		assertTrue(value, "Expected true, but got false");
	}
	
	public static void assertTrue(boolean value, String message) {
		if (!value) {
			throw new AssertionError(message); 
		}
	}
	
	public static void assertFalse(boolean value) {
		assertFalse(value, "Expected false, but got true");
	}
	
	public static void assertFalse(boolean value, String message) {
		assertTrue(!value, message);
	}
	
	public static void assertNotNull(Object value) {
		assertTrue(value != null, "Expected not-null object");
	}
	
	public static void assertNull(Object value) {
		assertTrue(value == null, "Expected null object");
	}
	
	public static void assertEquals(Object actual, Object expected) {
		assertEquals(actual, expected, "Expected '" + String.valueOf(expected) + "' but got '" + String.valueOf(actual) + "'");
	}

	public static void assertEquals(Object actual, Object expected, String message) {
		assertTrue((actual == null && expected == null) ||
				(actual != null && expected != null && actual.equals(expected)), message);
	}

	public static void fail() {
		fail("Failed by client");
	}
	
	public static void fail(String message) {
		assertTrue(false, message);
	}
	
	public static void skip() {
		skip("Skipped");
	}
	
	public static void skip(String message) {
		throw new SkipError(message);
	}
	
	public static class SkipError extends RuntimeException {
		private static final long serialVersionUID = 7764789779105491613L;

		private SkipError(String message) {
			super(message);
		}
	}
}
